package org.example.springbootwork.Reflection;

import org.example.springbootwork.Annotations.MyAnnotation;
import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.Annotation;

public class Test04 {
    public static void main(String[] args) throws ClassNotFoundException{
        //反射对象
        Class aClass = Class.forName("org.example.springbootwork.domain.User");
        //获得注解
        Annotation declaredAnnotation = aClass.getDeclaredAnnotation(MyAnnotation.class);

        if(declaredAnnotation instanceof MyAnnotation){
            MyAnnotation myAnnotations = (MyAnnotation)declaredAnnotation;
            //获得注解属性值
            System.out.println(myAnnotations.name());
        }

        if (declaredAnnotation instanceof RestController){
            System.out.println("declaredAnnotations is a RestController annotation");
        }else {
            System.out.println("declaredAnnotations is not a RestController annotation");
        }
    }
}
